package battleship;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;

public class OpenGamesServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("OpenGamesServlet: starting");
//        ArrayList<Game> openGames = Context.openGames;
//        Iterator<Game> iterator = openGames.iterator();
//        StringBuilder sb = new StringBuilder();
//        if (iterator.hasNext()) sb.append(iterator.next().player1.getUsername());
//        while (iterator.hasNext()) {
//            Game game = iterator.next();
//            User player = game.player1;
//            String username = player.getUsername();
//            sb.append("," + username);
//        }
//        String usernames = sb.toString();
//
//        response.setContentType("text/plain");
//        PrintWriter out = response.getWriter();
//        out.print(usernames);
//        out.close();
//        System.out.println("openGamesServlet: " + usernames);
//
//
        System.out.println("OpenGamesServlet: finished");
    }
}
